<template>
    <p>axios页</p>
    <button @click="getData">获取学生数据</button>

    <table>
        <tr>
            <th>学号</th>
            <th>姓名</th>
            <th>性别</th>
            <th>分数</th>
        </tr>
        <tr v-for="item in stundents">
            <td>{{ item.id }}</td>
            <td>{{ item.name }}</td>
            <td>{{ item.sex }}</td>
            <td>{{ item.score }}</td>
        </tr>
    </table>
</template>

<script>
export default {
    data(){
        return {
            stundents:[]
        }
    },
    methods:{
        getData(){
            this.$http
            .get('http://localhost:3000/stundents') // baseURL + /stundents ===>> http://localhost:3000/stundents
            .then(data =>{
                console.log(data);
                this.stundents = data
            })
        }
    }
}

</script>